﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MinimalistFoodStreet.BackEnd.Infrastructure.Dtos.Response;
using MinimalistFoodStreet.BackEnd.Infrastructure.EFCore;

namespace MinimalistFoodStreet.BackEnd.Server.Server.ResponseIqExtend
{
    public static class ResponseCommentPenddingIqExtend
    {
        public static IQueryable<ResponseCommentsPenddingDto> ToResponseCommentPenddingIq(this IQueryable<Order> iq)
        {
            return iq.Select(d => new ResponseCommentsPenddingDto()
            {
                orderTime = d.OCreateTime.ToString("yyyy-MM-dd"),
                goodComments = d.OrderDetails.Select(e => new ResponseGoodCommentsDto
                {
                    id = e.Comment != null ? e.Comment.CId : null,
                    good = new ResponseGoodList
                    {
                        id = e.OdGoodId,
                        name = e.OdName,
                        photo = e.OdPhoto,
                        price = e.OdPrice,
                        promotePrice = e.OdPromotePrice,
                        spec = e.OdSpecs
                    },
                    odid = e.OdId,
                    rate = e.Comment != null ? e.Comment.CRate : null
                }
                ).ToList()
            });
        }
    }
}
